#ifndef CURLING_CORE_INCLUDED
#define CURLING_CORE_INCLUDED

#include <boost/shared_ptr.hpp>
#include "config.hpp"

namespace curling {

class gui;
class renderer;
class game;

class core
{
public:

  core( int display_width, int display_height );
  ~core();
  
  void key_down( double t, int key, char character );
  void key_up( double t, int key, char character );
  void render( double t, double dt );
  
  bool requests_quit() const;
  void request_quit();
  
  void quit_event();
  void play_event();
  void pause_event();
  void options_event();
  void resume_event();
  void deliver_event( double direction, double power, double spin );
  void begin_sweep_event();
  void end_sweep_event();
  void fade_complete_event();
  /** Signals that the wait timer has reached 0. */
  void wait_over_event();
  void exit_event();
  
private:
  
  enum state
  {
    state_initial = 0,
    state_from_initial_to_credits,
    state_credits,
    state_from_credits_to_start_menu,
    //state_from_credits_to_main_menu,
    //state_main_menu,
    //state_from_main_menu_to_quit,
    //state_from_main_menu_to_start_menu,
    //state_from_main_menu_to_credits,
    //state_from_main_menu_to_options,
    state_start_menu,
    //state_from_start_menu_to_main_menu,
    state_from_start_menu_to_quit,
    state_from_start_menu_to_ingame,
    state_ingame,
    state_from_ingame_to_game_menu,
    state_game_menu,
    state_from_game_menu_to_ingame,
    //state_from_game_menu_to_main_menu,
    state_from_game_menu_to_start_menu,
    state_quit,
	state_options_menu
  };
  
  state _current_state;
  
  state current_state() const;
  void switch_state( state next_state );
  
  bool _requests_quit;
  
  boost::shared_ptr<gui> _gui;
  boost::shared_ptr<renderer> _renderer;
  boost::shared_ptr<game> _game;
  
  double wait_time;
};

}

#endif
